using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using LngT.Interfaces;
using LngTGUI;

namespace PL_DE_Lib
    {
    public partial class AddPL_DE_ItemForm: Form
        {
        public AddPL_DE_ItemForm()
            {
            InitializeComponent();
            }

        public static IItem GetItem()
            {
            AddPL_DE_ItemForm frm = new AddPL_DE_ItemForm();

            if( frm.ShowDialog() == DialogResult.OK )
                return new PL_DE_Item( frm.polishTextBox.Text, frm.germanTextBox.Text );
            else
                return null;
            }

        public static IItem GetItem(IItem item)
            {
            if( item == null )
                throw new ArgumentNullException( "item" );
            if( !( item is PL_DE_Item ) )
                throw new ArgumentException( "The given item is not a PL_DE_Item!" );
            AddPL_DE_ItemForm frm = new AddPL_DE_ItemForm();
            frm.polishTextBox.Text = ( item as PL_DE_Item ).Polish;
            frm.germanTextBox.Text = ( item as PL_DE_Item ).Deutsch;
            if( frm.ShowDialog() == DialogResult.OK )
                return new PL_DE_Item( frm.polishTextBox.Text, frm.germanTextBox.Text );
            else
                return null;
            }
        }
    }